package pxene.webmagic;

import java.util.HashMap;
import java.util.Map;

import pxene.webmagic.downloader.MyPhantomJsDownloader;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

public class Repo4Mydownloader implements PageProcessor {
	private final static String USER_AGENT="(Windows NT 6.2; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0";
	private Site site=Site.me().setCycleRetryTimes(3).setUserAgent(USER_AGENT);
	private static Map<String, Object> extras=new HashMap<String, Object>();
	
	
	public void process(Page page) {
		System.out.println(page.getRawText());
	}
	
	public Site getSite() {
		return site;
	}
	public static void main(String[] args) {
		String firePath="C:/Program Files (x86)/Mozilla Firefox/firefox.exe";
		String phjsPath="C:/Users/chenjinghui/Desktop/phantomjs-2.1.1-windows/bin/phantomjs.exe";
		Spider ZGCspider = Spider.create(new Repo4Mydownloader())
		.thread(10).addUrl("http://www.voidcn.com/blog/oSayMissyou0/article/p-4981746.html")
		.setDownloader(new MyPhantomJsDownloader(phjsPath));
		ZGCspider.start();
	}

}
